<?php
        define("GRID_SOURCE", "");       
        include(GRID_SOURCE."class/gridclasses.php"); //Include the grid engine.
        
        session_start();
        require_once "../funciones.php";
        $link_caweb = con_caweb();
        $result ="SELECT *  FROM intranetpccom.`taxonomia` WHERE `codigoclase` LIKE 'CAT'   ORDER BY taxDesc";
        $result=mysql_query($result,$link_caweb) or die('Error items, '.mysql_error());        
        
        $grid_id = array("grid");
        unset($_SESSION["grid"]);
        include(GRID_SOURCE."class/gridcreate.php"); //Creates grid objects.
?>
<html>
        <head>
                <title>Entrada Equipos / Aditamentos de Tercero</title>
                <script language="Javascript" type="text/javascript" src="<?php print(GRID_SOURCE);?>javascript/javascript.js"></script>
                <link href="<?php print(GRID_SOURCE);?>css/style.css" rel="stylesheet" type="text/css" />
                <link rel="stylesheet" type="text/css" media="screen" href="../css/caweb.css" />
				<script type='text/javascript' src="<?php print(GRID_SOURCE);?>server.php?client=all"></script>
				<script>
				HTML_AJAX.defaultServerUrl = '<?php print(GRID_SOURCE);?>server.php';
				</script>
		<script src="caweb2.js"></script>
            <script src="../js/jquery.js" type="text/javascript"></script>
            <script src="../js/caweb.js" type="text/javascript"></script>
        <script>
            function validar(e) {
                var tecla;
            	
                if (document.all) { tecla = e.keyCode;  } 
                else {  tecla = e.which; }
                if (tecla == 13) { $('#serial').focus(); }
                else { return false; }
            }
            
            function validar2(e) {
                var tecla;
            	
                if (document.all) { tecla = e.keyCode;  } 
                else {  tecla = e.which; }
                if (tecla == 13 && $('#item').val() != 'XXX') {  
                    $('#guardar2').attr('disabled','');  
                    $('#interno').focus(); }
                else { return false; }
            }
            
        </script>
        </head>

        <body onload="$('#interno').focus();">
	
		<form name="ete" method="POST" action="adiciona0_cant.php?op=ete&cliente=<?php echo $_REQUEST[cliente]; ?>">
            <table border=0>
                <tr>
                    <td>
                    <div><label for="clasetx">Clase</label>
                        <select name="clase" id="clasetx" class="mayusculas" onchange="funcion_subclases(this.value,1,'1');funcion_pasasesion('clase',this.value);">
                        <option value='' SELECTED>Seleccionar..</option>
                        <?php
                            $link_intranetpccom = con_intranetpccom();
                            $result = "SELECT * FROM taxonomia where codigotaxonomia like 'C%' or codigotaxonomia like 'I%'  or codigotaxonomia like 'M%' or codigotaxonomia like 'O%' order by taxDesc";
                            $result = mysql_query($result, $link_intranetpccom) or die("Error Taxonomia ".mysql_error());
                            $sql ="select cla.codigoclase,cla.descripcion from taxonomia tax
                                    inner join clases cla on tax.codigoclase = cla.codigoclase and cla.estado = 1
                                    where tax.porcantidad = 'Si' and tax.estado = 1
                                    group by codigoclase order by cla.descripcion";
                            $result64=mysql_query($sql,$link_intranetpccom) or die('Error Clase, '.mysql_error().$sql);
                            while($row64 = mysql_fetch_array($result64)){
                                echo "<option value='{$row64['codigoclase']}'>{$row64['descripcion']}</option>";
                            }
                        ?>
                    </select>
                    </div>
            </td>
            <td>
                <div id="layer2_subclases"></div>
            </td>
            <td>
                <div id="layer2_familias"></div>
            </td>
            <td>
                <div id="layer2_grupos"></div>
            </td>
            </tr>
                <tr>
                    <td colspan="8">
            Calidad:
	        <select name="lectura2" id="lectura2" size="1" value="XXX" onchange="$('#calidad').attr('value',this.value);">
    	    <option value="XXX" SELECTED>Seleccione...</option>
        	<option value="C">Conforme</option>
        	<option value="NC">NO Conforme</option>
        	</select>
            Cantidad :<input type="text" id="cantidad" size="5" name="cantidad" value="" />
            Detalles :<input type="text" id="observacion" size="30" name="observacion" value="" />
            <input type="hidden" name="codigosubclase" id="codigosubclase" />
            <input type="hidden" name="calidad" id="calidad"/>
            <input name="guardar" id="guardar" type="submit" value="Adicionar" />
            </td>
                </tr>
   			</table>
            
    	</form>
		
            <font size="5">Equipos</font>
            <br />
        
		<form name="ete2" method="POST" action="adiciona_ete.php?cliente=<?php echo $_REQUEST[cliente]; ?>">
            Tipo:   <select name="item" id="item" size="1" class="mayusculas" onchange="
            $('#interno').attr('disabled','');
            $('#serial').attr('disabled',''); 
            $('#velocidad').focus(); funcion_pasasesion('ultimoitem',this.value); ">
            <option value="XXX">Seleccionar..</option>
            <?
                while($row = mysql_fetch_array($result))
                {
                    ?> <option value="<? echo $row["codigotaxonomia"]; ?>" <?php if($row["codigotaxonomia"]==$_SESSION['caweb']['ultimoitem']) echo "selected";  ?> >  <? echo $row["taxDesc"]; ?> </option> <?
                }
            ?>
            
            </select>
            <br />
            LINEAL: Velocidad <input type="text" id="velocidad" size="8" name="velocidad" value="<?php echo $_SESSION['caweb']['ultimovelocidad'];  ?>" onblur="funcion_pasasesion('ultimovelocidad',this.value);"/>
            Board <input type="text" id="board" size="8" name="board" value="<?php echo $_SESSION['caweb']['ultimoboard'];  ?>" onblur="funcion_pasasesion('ultimoboard',this.value);"/>
            Disco <input type="text" id="disco" size="8" name="disco" value="<?php echo $_SESSION['caweb']['ultimodisco'];  ?>" onblur="funcion_pasasesion('ultimodisco',this.value);"/>
            Memoria <input type="text" id="memoria" size="8" name="memoria" value="<?php echo $_SESSION['caweb']['ultimomemoria'];  ?>" onblur="funcion_pasasesion('ultimomemoria',this.value);"/>
            Video <input type="text" id="video" size="8" name="video" value="<?php echo $_SESSION['caweb']['ultimovideo'];  ?>" onblur="funcion_pasasesion('ultimovideo',this.value);"/>
            Red <input type="text" id="red" size="8" name="red" value="<?php echo $_SESSION['caweb']['ultimored'];  ?>" onblur="funcion_pasasesion('ultimored',this.value);"/>
            Fax <input type="text" id="fax" size="8" name="fax" value="<?php echo $_SESSION['caweb']['ultimofax'];  ?>" onblur="funcion_pasasesion('ultimofax',this.value);"/>
            Opticos <input type="text" id="opticos" size="8" name="opticos" value="<?php echo $_SESSION['caweb']['ultimoopticos'];  ?>" onblur="funcion_pasasesion('ultimoopticos',this.value);"/>
            <br />
            Interno: <input type="text" id="interno" size="30" name="interno" value="" onkeypress="validar(event);"/>
            Serial:  <input type="text" id="serial" size="30" name="serial" value="" onkeypress="validar2(event); "/>
            <input name="guardar2" id="guardar2" type="submit" value="Adicionar" disabled="disabled"/>
        </form>
        
        <?php
$link_caweb = con_caweb();
			$transaccion=$_SESSION['caweb']['consecutivo'];
			echo  "Ultimo Interno ".$_SESSION['caweb']['ultimointerno'];
			if ($_SESSION['caweb']['resultado'] == 0) { echo "<font color=red size=4><b> CREAR ITEM NUEVO </b></font>"; }
		 	if ($_SESSION['caweb']['resultado'] == 1) { echo "<font color=green size=4><b> CORRECTO </b></font>"; }
            if ($_SESSION['caweb']['resultado'] == 3) { echo "<font color=red size=4><b> Error, Interno en esta transaccion </b></font>"; }
            if ($_SESSION['caweb']['resultado'] == 4) { echo "<font color=orange size=4><b>Ojo, Interno ya existe. Se actualizara porque su estado es D (Disponible)</b></font>"; }
            
            if ($_SESSION['caweb']['resultado'] == 6) { echo "<font color=red size=4><b> ERROR.. INTERNO asignado o Vigente </b></font>"; }
            
			$consecutivo=$_SESSION['caweb']['consecutivo'];
			$condicion="transaccion='$consecutivo'";
   			$_SESSION["grid"]->SetDatabaseConnection($_SESSION['caweb']['basededatos'], "caweb", "caweb");

           	$_SESSION["grid"]->SetSqlSelect('id, interno, item, serial, cantidad, velocidad, board, disco, memoria, optico', 'temporal', $condicion);
			$_SESSION["grid"]->SetUniqueDatabaseColumn("id", false);
			$_SESSION["grid"]->SetTitleName("(Transaccion: $transaccion) - Equipos / Elementos para Entrada de Tercero ");
			$_SESSION["grid"]->SetEditModeEdit(true);
			$_SESSION["grid"]->SetMaxRowsEachPage(15);
            $_SESSION["grid"]->SetDatabaseColumnEditable("id", false);
			$_SESSION["grid"]->SetDatabaseColumnEditable("interno", true);
   	        $_SESSION["grid"]->SetDatabaseColumnEditable("item", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("serial", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("velocidad", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("board", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("disco", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("memoria", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("optico", true);
			$_SESSION["grid"]->SetShowExcelIco(false);
			$_SESSION["grid"]->SetShowPrintIco(true);
			$_SESSION["grid"]->PrintGrid(MODE_EDIT);
	
                ?>
        </body> 
</html>